package hot100;

public class hasCycle {
    public boolean hasCycle(mergeKLists.ListNode head) {
        if(head==null || head.next == null) {
            return false;
        }
        mergeKLists.ListNode slow = head;
        mergeKLists.ListNode fast = head;
        while(fast != null &&fast.next != null) {
            fast = fast.next.next;
            slow = slow.next;
            if(fast == slow) {
                return true;
            }
        }
        return false;

    }
}
